{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form id="img-form" enctype="multipart/form-data">
    {% csrf_token %}
    <p>{{media}}</p>
    <img src="{{MEDIA_URL}}{{media}}" width=200px />
    <img src="{{MEDIA_URL}}img/OIP-C.jpg" />
    <div style="margin: 50px;">
        <input type="file" name="img" id="img">
    </div>
    <div style="margin: 50px;">
        <input  type="button" value="提交">
    </div>
</form>

<script type="text/javascript" src="{% static 'js/jquery-3.7.1.min.js' %}"></script>
{% comment %} <script type="text/javascript">
    function upload_img() {
        let formData = new FormData($("#img-form")[0]);
        $.ajax({
            url: "/uploadimg/", //请求路径
            type: 'POST', // 请求类型
            data: formData, // 请求数据
            dataType: "JSON", // 返回数据格式
            contentType: false, //表示不处理数据
            processData: false,
            cache: false,
            success: function (data) {
                if (data === 1) { 
                    alert("上传成功");
                }else if (data === 0) {
                    alert("上传失败");
                }
            },
            error: function (data) {
                console.log(data);
            }
        });
    }
</script> {% endcomment %}
</body>
</html>